<?php

namespace App\Http\Controllers;

use App\Models\Goods;
use Illuminate\Http\Request;

class GoodsController extends BaseController
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request,Goods $goods)
    {
        $data=$request->all();
        $goods->title=$data['title'];
        $goods->content=$data['content'];
        $goods->read_num=$data['read_num'];
        $goods->hot_bot=$data['hot_bot'];
        if($data['id']){
            $goods->exists = true;
            $goods->id = $data['id'];
        }
        try{
            if (!$goods->save()) {
                Log::addLogs(trans('xxm.article.handle_article').trans('fzs.common.success'),'/article/story');
                return $this->resultJson(trans('fzs.common.fail'),0);
            }else{
                Log::addLogs(trans('xxm.article.handle_article').trans('fzs.common.fail'),'/article/store');
                return $this->resultJson(trans('fzs.common.success'),1);
            }
        }catch (\Exception $e){
            Log::addLogs(trans('xxm.article.handle_article').trans('fzs.common.fail'),'/article/story');
            return $this->resultJson(trans('fzs.common.fail'),0);
        }
    }

    /**
     * Display the specified resource.
     *
     * @param  \App\Models\Goods  $goods
     * @return \Illuminate\Http\Response
     */
    public function show(Goods $goods)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\Models\Goods  $goods
     * @return \Illuminate\Http\Response
     */
    public function edit(Goods $goods)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\Goods  $goods
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, Goods $goods)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\Models\Goods  $goods
     * @return \Illuminate\Http\Response
     */
    public function destroy(Goods $goods)
    {
        //
    }
}
